package com.fen.testdemo.async;

import java.util.HashMap;
import java.util.Map;

public class Test {

   public static void main(String[] args) throws Exception { 
       RpcService rpcService = new RpcService(); 
       HttpService httpService = new HttpService(); 
       //耗时10ms 
       Map<String, String> result1 = rpcService.getRpcResult();
       //耗时20ms 
       Integer result2 = httpService.getHttpResult(); 
       //总耗时30ms 
    } 
   static class RpcService { 
       Map<String, String> getRpcResult() throws Exception { 
           //调用远程方法（远程方法耗时约10ms，可以使用Thread.sleep模拟）
           Thread.sleep(10000);
           return new HashMap<>();
       } 
    } 
   static class HttpService { 
       Integer getHttpResult() throws Exception { 
           //调用远程方法（远程方法耗时约20ms，可以使用Thread.sleep模拟） 
           Thread.sleep(20000);
           return 0; 
       } 
    } 
} 